import cv2

# 读取图片
# image = cv2.imread('../images/1.jpg')
# #  打印图片的形状、即高宽和通道数
# h, w, c = image.shape
# print(h, w, c)
#
# # 打印（60， 60）的像素点的rgb值
# pixel = image[60, 60]
# print(pixel)
#
# # 创建一个空数组和图像格式大小相同
# pixels = np.zeros((h, w, c), dtype=np.uint8)
# # 遍历每一个像素点
# for y in range(h):
#     for x in range(w):
#         # 获取像素点的数组
#         pixel = image[y, x]
#         # 将像素点的数组存储到新数组中
#         pixels[y, x] = pixel
#
# # 打印结果
# print(pixels)
# 将图片转换为灰度图
image = cv2.imread('C:\\Users\\tianchengz\\Downloads\\1.jpg')
# 将图像转换为灰度图
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# 保存到images路径下并命名为GRAY
# 对灰度图像进行阈值处理，生成水印的二值掩码
_, mask = cv2.threshold(gray, 200, 255, cv2.THRESH_BINARY)

# 使用掩码修复图像
inpainted_image = cv2.inpaint(image, mask, inpaintRadius=3, flags=cv2.INPAINT_TELEA)

# 保存或显示处理后的结果
cv2.imwrite('output_image.jpg', inpainted_image)
cv2.imshow('Inpainted Image', inpainted_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

# 等待键盘输入，参数为0表示一直等待，直到按下任意键
cv2.waitKey(0)

if __name__ == "__main__":
    pass

